let table_name = "circle_article_list_table";
let table_data_url = "/sys/circle/article/list/list";
let number_list = "<'row'<'#mytool.col-xs-3'><'col-xs-9'>><'row'<'.col-xs-12'tr>><'row'<'#num_menu.col-xs-2'l><'col-xs-10'p>>";

function action_status() {
}

let dataManage = {
    currentItem: null,
    fuzzySearch: true,
    getQueryCondition: function (data) {
        let param = {};
        param.start = data.start;
        param.length = data.length;
        return JSON.stringify(param);
    },
};

let returnData = {
    getDate: [
        {
            className: "ellipsis",
            data: "",
            render: CONSTANT.DATA_TABLES.RENDER.ELLIPSIS,
            orderable: false,
            width: "50px"
        }, {
            className: "ellipsis",
            data: "title",
            render: CONSTANT.DATA_TABLES.RENDER.ELLIPSIS,
            orderable: false,
            width: "50px"
        },
        {
            className: "ellipsis",
            data: "content",
            orderable: false,
            width: "50px",
            render:CONSTANT.DATA_TABLES.RENDER.ELLIPSIS,
        }, {
            className: "ellipsis",
            data: "type",
            render: function (data, type, row, meta) {
                if (row.type === 1) {
                    return '普通';
                }else if(row.type === 2){
                    return "问答";
                }else{
                    return "找人做事";
                }
            },
            orderable: false,
            width: "50px"
        },{
            className: "ellipsis",
            data: "quintessence",
            render: function (data, type, row, meta) {
                if (row.quintessence === 1) {
                    return '否';
                }else{
                    return "是";
                }
            },
            orderable: false,
            width: "50px"
        }, {
            className: "ellipsis",
            data: "tag",
            render: function (data, type, row, meta) {
                if (row.tag === 1) {
                    return '普通帖';
                }else{
                    return "热帖";
                }
            },
            orderable: false,
            width: "50px"
        },{
            className: "ellipsis",
            data: "recommend",
            render: function (data, type, row, meta) {
                if (row.recommend === 1) {
                    return '否';
                }else{
                    return "是";
                }
            },
            orderable: false,
            width: "50px"
        },
        {
            className: "ellipsis",
            data: "topStatus",
            render: function (data, type, row, meta) {
                if (row.topStatus === 1) {
                    return '否';
                }else{
                    return "是";
                }
            },
            orderable: false,
            width: "50px"
        },
        {
            className: "ellipsis",
            data: "",
            orderable: false,
            width: "50px",
            render: function (data, type, row, meta) {
                let button = '';
                if (row.quintessence === 1) {
                    button += '<button class="btn btn-sm btn-success" onclick=update_status(' + row.id + ',2,1)>精华</button>';
                } else {
                    button += '<button class="btn btn-sm btn-success" onclick=update_status(' + row.id + ',1,1)>非精华</button>';
                }

                if (row.recommend === 1) {
                    button += '<button class="btn btn-sm btn-success" onclick=update_status(' + row.id + ',2,2)>推荐首页</button>';
                }else{
                    button += '<button class="btn btn-sm btn-success" onclick=update_status(' + row.id + ',1,2)>不推荐首页</button>';
                }

                if (row.tag === 1) {
                    button += '<button class="btn btn-sm btn-success" onclick=update_status(' + row.id + ',2,3)>热帖</button>';
                }else{
                    button += '<button class="btn btn-sm btn-success" onclick=update_status(' + row.id + ',1,3)>普通帖</button>';
                }

                if (row.topStatus === 1) {
                    button += '<button class="btn btn-sm btn-success" onclick=update_status(' + row.id + ',2,4)>置顶</button>';
                }else{
                    button += '<button class="btn btn-sm btn-success" onclick=update_status(' + row.id + ',1,4)>不置顶</button>';
                }

                button += '<button class="btn btn-sm btn-danger" onclick=circle_article_delete(' + row.id + ')>删除</button>';
                return button;
            }
        }
    ]
}

function foot_info(result) {
}

function createdRow(row, data, index) {
    if (data.role) {
        $(row).addClass("info");
    }
}

function drawCallback(settings) {
}

function search_user() {
    find();
}

function fn_draw_call_back() {
}

function create_circle_list() {
    $('#circle_list_modal').modal('show');
}


function update_status(Id, status,type) {
    HttpUtils.post_json('/sys/circle/article/list/update/status', JSON.stringify({
        'id': Id,
        'status': status,
        'updateType':type
    }), function (result) {
        success_msg("更新成功", function () {
            $('#circle_article_list_delete_modal').modal('hide');
            find();
        });
    });
}

function circle_article_delete(Id) {
    $('#circle_article_list_id').val(Id);
    $('#circle_article_list_delete_modal').modal('show');
}


function ack_delete_circle_article_list() {
    let id = $('#circle_article_list_id').val();
    let msg = $('#msg').val();
    HttpUtils.post_json('/sys/circle/article/list/delete', JSON.stringify({
        'id': id,
        'msg': msg
    }), function (result) {
        success_msg("更新成功", function () {
            find();
        });
    });
}

modalClose('circle_article_list_delete_modal', function () {
    $('#msg').val('');
});
